import { createApp } from "vue";
import router from "@/router";
import pinia from "@/stores";

import "@/assets/main.less";
// 全局样式文件
import "@/styles/index.scss"; // global css
import "element-plus/dist/index.css";
import App from "./App.vue";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";

// svg
import "virtual:svg-icons-register";
// 引入SvgIcon.vue组件
import SvgIcon from "@/components/SvgIcon.vue";
const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.use(ElementPlus, {
  locale: zhCn,
});
// 将SvgIcon.vue组件注册为全局组件
app.component("svg-icon", SvgIcon);
import { addDynamicRoutes } from "@/router/permission";
const savedDynamicRouters = JSON.parse(
  sessionStorage.getItem("routes") || "[]"
);
if (savedDynamicRouters) {
  console.log("savedDynamicRouters", savedDynamicRouters);
  addDynamicRoutes(savedDynamicRouters); // 初始化动态路由
}
app.use(router);
app.use(pinia);
app.mount("#app");
